<template>
  <div>
    <h2>练习二</h2>
    <ul>
      <li v-for="(item,index) in num" :key="index">
        <span>{{item}}</span><button @click="fn(index)">删除</button>
      </li>
    </ul>
    <button @click="add">生成</button>
  </div>
</template>

<script>
export default {
data() {
 return{
num:['1','5','3']
 } 
},
methods:{
  fn(index) {
    this.num.splice(index,1)
  },
  add(){
     this.num.push(Math.floor(Math.random() * 20));
  }
}
}
</script>

<style>

</style>